﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using WebLibs;

namespace MDF.DataHelper.BussinessLogic
{
    public class BaseBussinessLogic
    {
        protected IData m_objData = null;
        private bool isAutoConnect = true;
        protected void BeginTran()
        {
            if (this.m_objData == null)
            {
                this.m_objData = new IData();
                this.m_objData.Connect();
                this.m_objData.Transaction = this.m_objData.GetConnection().BeginTransaction();
            }
            else
            {
                isAutoConnect = false;
            }
        }
        protected void CommitTran()
        {
            if (isAutoConnect)
            {
                this.m_objData.Transaction.Commit();
                this.m_objData.DeConnect();
                this.m_objData = null;
            }
        }
        protected void RollbackTran()
        {
            if (isAutoConnect)
            {
                this.m_objData.Transaction.Rollback();
                this.m_objData.DeConnect();
                this.m_objData = null;
            }
        }
    }
}
